-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lsp): create a proper way of removing items from skipped_servers #2503
Conversation
I must've copied the snippet wrong somewhere, because it should've been using lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(s)
return s ~= "tailwindcss"
end, lvim.lsp.automatic_configuration.skipped_servers) which as you can see, is not that easy to read/follow 🥲 I've been contemplating adding a function similar to what you have created, but instead have it directly accessible ---remove a server or list of servers from automatic configuration's skiplist
---@param s string|table can be a string or a list of strings, e.g. "tailwindcss" or {"emmet_ls", "eslint"}
local function unskip(s)
if type(s) == "string" then
s = { s }
end
for _, item in ipairs(s) do
tbl_remove(lvim.lsp.automatic_configuration.skipped_servers, item)
end
end
lvim.lsp.automatic_configuration.unskip = unskip -- could instead be called "enable" or something |
with the function that you suggested, we would have three categories
which is a bit weird |
I was thinking of it more of a helper, but you're right, it's adding to the confusion instead of helping 😄 One thing I also realized is that removing servers from the skipped list was only necessary when the installer wasn't allowed to run for them, but that has changed in require("lvim.lsp.manager").setup("tailwindcss", {}) pros
cons
|
hmm, it just got interesting 😅 |
as a quick and easy solution, I would remove the snippet entirely from -- all ts/js servers are skipped by default except for tsserver
require("lvim.lsp.manager").setup("tailwindcss", {}) and then fix this snippet on the site https://www.lunarvim.org/troubleshooting/#is-it-overriden lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(s)
return s ~= "tailwindcss"
end, lvim.lsp.automatic_configuration.skipped_servers) |
so which one do you prefer? lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(s)
return s ~= "tailwindcss"
end, lvim.lsp.automatic_configuration.skipped_servers) or local tbl = require "lvim.utils.table"
tbl.remove(lvim.lsp.automatic_configuration.skipped_servers, "tailwindcss") ? |
I'll try to get some opinions on discord about this. Another potential contender is implementing a |
Is there a way to skip multiple servers. It would be nice to have something like I used to do |
do you mean for un-skipping? because calling the either way, it's just a simple lua table that you can alter however you want :lua =lvim.lsp.automatic_configuration.skipped_servers |
This is not working: require("lvim.lsp.manager").setup("tailwindcss") This is working: local unskipServers = { "tailwindcss", "eslint" }
for _, item in ipairs(unskipServers) do
lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server)
return server ~= item
end, lvim.lsp.automatic_configuration.skipped_servers)
end The bad thing about this is every project now runs this server whether or not tailwind/eslint is configured in the project. I dont know either neovim config or lua and hacked around using the code above. |
@namimo, the change to unblock tailwindcss was recent #2870, so you don't need to alter it anymore. for -- in ~/.config/lvim/after/ftplugin/typescript.lua
local util = require "lspconfig.util"
local opts = {
root_dir = util.root_pattern(
".eslintrc",
".eslintrc.js",
".eslintrc.cjs",
".eslintrc.yaml",
".eslintrc.yml",
".eslintrc.json"
),
}
require("lvim.lsp.manager").setup("eslint", opts) you could duplicate in other ftplugin files (that's how lunarvim works internally), or you could also set it up once in |
Should we close this due to #2887 ? |
the root cause of tis was that the tbl_map was not properly understood/used. I never had a single reliability problem with it, and I worked already on several macs (both x86 and M1). |
-- @param t The table | ||
-- @param value The item to remove | ||
-- @return True if item was removed, false otherwise | ||
function Table.remove(t, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutation a function input is a bad idea. Built-in table filter has a better API in my opinion. Creating a new table and returning that is the best and safest way to proceed.
Description
vim.tbl_map
is unreliable (especially on mac), so just provide a simple function to remove item from mapfor example you can add this to your
config.lua
Fixes #2501